import {type ConfigType, Dayjs} from "dayjs";

export const dateFormat: string = 'YYYY-MM-DD';
export const dateTimeFormat: string = 'YYYY-MM-DD';

export default class DayjsEx extends Dayjs {

    constructor(config: ConfigType) {
        super(config);
    }

    public toDateString(): string {
        return this.format(dateFormat);
    }

    public toDateTimeString(): string {
        return this.format(dateTimeFormat);
    }

    public addDay(day: number): DayjsEx {
        this.add(1, 'day');
        return this;
    }
}

export const dayjs1 = (date?: ConfigType): DayjsEx => {
    return new DayjsEx(date);
}

